package com.sangeng.controller;


import com.sangeng.annotation.SystemLog;
import com.sangeng.domain.ResponseResult;
import com.sangeng.domain.dto.AddUserDto;
import com.sangeng.domain.dto.UserDto;
import com.sangeng.domain.entity.User;
import com.sangeng.domain.vo.UserInfoVo;
import com.sangeng.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 用户表(User)表控制层
 *
 * @author makejava
 * @since 2024-08-26 19:15:31
 */
@RestController
@RequestMapping("system/user")
public class UserController {
    /**
     * 服务对象
     */
    @Autowired
    private UserService userService;

    @SystemLog(businessName = "用户列表展示接口")
    @GetMapping("/list")
    public ResponseResult getUserList(Long pageNum ,Long pageSize,String userName,String phonenumber,String status){
       return userService.getUserList(pageNum,pageSize,userName,phonenumber,status);
    }

    @SystemLog(businessName = "新增用户接口")
    @PostMapping
    public  ResponseResult addUser(@RequestBody AddUserDto addUserDto){
       return userService.addUser(addUserDto);
    }

    @SystemLog(businessName = "删除用户接口")
    @DeleteMapping("/{id}")
    public ResponseResult deleteUser(@PathVariable Long id){
        return  userService.deleteUser(id);
    }


    @SystemLog(businessName = "修改用户回显接口")
    @GetMapping("/{id}")
    public ResponseResult getUserById(@PathVariable Long id){
       return   userService.getUserById(id);
    }

    @SystemLog(businessName = "修改用户信息接口")
    @PutMapping()
    public ResponseResult updateUser(@RequestBody UserDto userDto){
       return userService.updateUser(userDto);
    }

    //TODO 用户禁用和停用
    @SystemLog(businessName = "用户禁用和停用")
    @PutMapping("/changeStatus")
    public ResponseResult changeUserStatus(@RequestBody User user){
       return   userService.changeUserStatus(user);
    }
}

